<?php
ob_start();
session_start();
include '../../operations/connection.php';

if(!$_SESSION['user'])
{
	header( 'Location: login.php' );
}
else
{
	$username = $_SESSION['fullname'];
	$id_employee = $_SESSION['IDEmployee'];
}

$langVN = $_REQUEST['cvietnam'];
$deptnameVN = $_REQUEST['deptnameVN'];
$locationVN = $_REQUEST['locationVN'];
$descriptionVN = $_REQUEST['descriptionVN'];

$langEN = $_REQUEST['cenglish'];
$deptnameEN = $_REQUEST['deptnameEN'];
$locationEN = $_REQUEST['locationEN'];
$descriptionEN = $_REQUEST['descriptionEN'];

$langKR = $_REQUEST['ckorea'];
$deptnameKR = $_REQUEST['deptnameKR'];
$locationKR = $_REQUEST['locationKR'];
$descriptionKR = $_REQUEST['descriptionKR'];


if(isset($_REQUEST['createdept'])){
	$insertdept =mysql_query("insert into department(lang) values('null')");
	$selectdept = mysql_query("SELECT IDDepartment FROM department ORDER BY IDDepartment DESC LIMIT 0, 1");
	$row = mysql_fetch_assoc($selectdept);
	$rowIDDept = $row[IDDepartment];
	
	$insertdeptlangVN = "insert into department_lang(IDDepartment,LangID,DepartmentName,Location,Description)
		 values($rowIDDept,'VN','$deptnameVN','$locationVN','$descriptionVN')";
	$insertdeptlangEN = "insert into department_lang(IDDepartment,LangID,DepartmentName,Location,Description)
		 values($rowIDDept,'EN','$deptnameEN','$locationEN','$descriptionEN')";
	$insertdeptlangKR = "insert into department_lang(IDDepartment,LangID,DepartmentName,Location,Description)
		 values($rowIDDept,'KR','$deptnameKR','$locationKR','$descriptionKR')";
	
	mysql_query($insertdeptlangVN);
	mysql_query($insertdeptlangEN);
	mysql_query($insertdeptlangKR);
}
mysql_close($connection);


if(isset($_REQUEST['createdept'])){
	$_SESSION['alertregister'] ="";
	header("Location: ../../deparment-admin.php");
}
ob_flush();

?>